import java.util.Iterator;

class ListDefinition1<T>  implements Iterable, Iterator {
	
	Object[] element;
	int capacity;
	int cind;
	int lastind;
	
	public ListDefinition1(int c){
		element=new Object[c]; 
		capacity=0;
		cind=0;
		lastind=0;
	}
	
	T get(int ind){
		T a = (T) element[ind];
		return a;
	}

	void insert(T a, int ind){
		for (int i=ind;i<capacity;i++){
			element[i+1]=element[i];
		}
		element[ind]=a;
		capacity++;
		lastind++;
	}

	T delete(int ind){
		T a; 
		a=(T) element[ind];
		for (int i=ind;i<capacity;i++){
			element[i]=element[i+1];
		}
		capacity--;
		lastind--;
		return a;
	}
	
	public Iterator iterator(){
		return  this;
	}

	public boolean hasNext(){
		if (cind<lastind)
		{return true; }
		else
		{return false; }
	}

	public Object next(){
		return this.get(cind++);
	}

	public void remove() {
		this.delete(cind);
	}
	
}

public class MakeList {

	public static void main(String[] args) {

		ListDefinition1<Integer> a = new ListDefinition1<Integer>(10);	
		
		for (int v=0;v<10;v++){
			a.insert(v+1,v);
		}

		Iterator it=a.iterator();
		
/*		while (it.hasNext()){
			System.out.println(it.next());
		}*/

		for(Object i: a){
			System.out.println(i);
		}
	
	}

}
